<template>
	<el-card shadow="hover" header="待办任务" class="item-background">
        <div style="padding: 20px 20px 0;">
        <el-tabs v-model="activeName">
            <el-tab-pane label="课程审核" name="one">
                <div style="height: 355px; ">
                    <scTable ref="table" :params="search" :apiObj="apiObj" stripe remoteSort remoteFilter>
                        <el-table-column align="left" label="课程名称" prop="name"></el-table-column>
                        <el-table-column align="center" label="课程分类" prop="category_name" width="120px">
                            <template #default="scope">
                                {{scope.row.category ? scope.row.category.name : ''}}
                            </template>
                        </el-table-column>
                        <el-table-column align="center" label="课节数量" prop="classSectionNumber" width="80px"></el-table-column>
                        <el-table-column align="center" label="总学时（分钟）" width="120px">
                            <template #default="scope">
                                {{scope.row.classHour}}
                            </template>
                        </el-table-column>
                        <el-table-column align="center" label="所属机构" width="120px">
                            <template #default="scope">
                                {{scope.row.company && scope.row.company.name}}
                            </template>
                        </el-table-column>
                        <el-table-column align="center" label="排序号" prop="sort" width="60px"></el-table-column>
                        <!-- <el-table-column align="center" label="创建时间" prop="createdAt" width="180px"></el-table-column> -->
                        <el-table-column align="center" label="状态" width="80px">
                            <template #default="scope">
                                <el-tag size="mini" type="info" v-if="scope.row.status.val === 0 || scope.row.status.val === -1">{{scope.row.status.name}}</el-tag>
                                <el-tag size="mini" v-if="scope.row.status.val == 1" type="success">{{scope.row.status.name}}</el-tag>
                                <el-tag size="mini" v-if="scope.row.status.val == 2 || scope.row.status.val == -2" type="danger">{{scope.row.status.name}}</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" fixed="right" align="center" width="150">
                            <template #default="scope">
                                <el-button type="text" size="small" @click="detail(scope.row)">查看</el-button>
                            </template>
                        </el-table-column>
                    </scTable>
                </div>
            </el-tab-pane>
            <el-tab-pane label="意见反馈" name="two">
                <div style="height: 355px; ">
                    <scTable ref="table" :apiObj="$API.message.facebak.list" remoteSort>
                        <el-table-column label="发送人" prop="status" width="150">
							<template #default="scope">
								<span>{{scope.row.sender.name}}</span>
							</template>
						</el-table-column>
                        <el-table-column label="类型" prop="status" width="150">
							<template #default="scope">
								<span>{{scope.row.category.name}}</span>
							</template>
						</el-table-column>
						<el-table-column label="内容" prop="content"></el-table-column>
                        <el-table-column label="状态" prop="status" width="150">
							<template #default="scope">
								<el-tag size="mini" type="info">{{scope.row.status.name}}</el-tag>
							</template>
						</el-table-column>
						<el-table-column label="操作" fixed="right" align="right" width="140">
                            <template #default="scope">
								<el-button type="text" size="small" @click="table_show(scope.row)">查看</el-button>
								<el-divider direction="vertical"></el-divider>
                                <el-popconfirm title="确定删除吗？" @confirm="table_del(scope.row, scope.$index)">
                                    <template #reference>
                                        <el-button type="text" size="small">删除</el-button>
                                    </template>
                                </el-popconfirm>
							</template>
						</el-table-column>
					</scTable>
                </div>
            </el-tab-pane>
        </el-tabs>
		</div>
	</el-card>

</template>

<script>
	export default {
		title: "关于项目",
		icon: "el-icon-s-tools",
		description: "关于项目介绍",
        components: {
		},
		data() {
			return {
                activeName: 'one',
				dialog: {
					save: false
				},
				apiObj: this.$API.course.course.list,
				search: {
					categoryId: [],
					name: null,
					status: [-1, -2]
				},
				ohter_status: '',
				company_list: [],
				companyId: '',
				categories: [],
				statusStatisticsNumber: [],
				courseTotalNumber: 0
			}
		},
        methods: {
			//课程审核
			examine(row){
				this.dialog.save = true
				this.$nextTick(() => {
					this.$refs.saveDialog.open().setData(row)
				})
			},
			//获取所有机构
			async getAllCompany(){
				let res = await this.$API.system.company.getAllCompany.get({type: 3});
				if(res.error == 0){
					this.company_list = res.data
				}
			},
			//添加
			addCourse() {
				this.$refs.saveDialog.open(null)
			},
            // 搜索
			upsearch(){
				let param = {}
				if(this.ohter_status){
					this.search.status = [this.ohter_status]
				}else{
					this.search.status = [-1, -2]
				}
				for(let key in this.search) {
					if (key === 'categoryId') {
						if (this.search['categoryId']) {
							param['categoryId'] = this.search['categoryId'][this.search['categoryId'].length - 1]
						}
						continue
					}
					param[key] = this.search[key]
				}
				param['companyId'] = this.companyId
                this.$refs.table.upData(param)
            },
			async deleteCoruse(info) {
				this.loading = true
				var res = await this.$API.examination.exam.action.delete({id: info.id});
				this.loading = false
				if (res.error == 0) {
					this.$notify.success('删除成功');
				}
			},
			detail(info) {
				this.$refs.detailDialog.open(info.id, info.company.id)
			},
			//本地更新数据
			handleSuccess(){
				this.$refs.table.refresh()
				this.$refs.detailDialog.visible = false
			},
            //查看
			async table_show(row){
				this.dialog.show = true
				this.$nextTick(() => {
					this.$refs.showDialog.open().setData(row)
				})
			},
			//删除
			async table_del(row, index){
				var res = await this.$API.message.facebak.action.delete({id: row.id});
				if(res.error == 0){
					this.$refs.table.tableData.splice(index, 1);
					this.$refs.table.total = this.$refs.table.total - 1
					this.$notify.success("删除成功")
				}else{
					// this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}
	}
</script>

<style scoped>
	.item-background p {color: #999;margin-top:10px;line-height: 1.8;}
</style>
